#include "ddl.h"
#include "uart.h"
#include "gpio.h"
#include "sysctrl.h"
#include "led.h"

#include "stdbool.h"



void led_init(void)
{
    stc_gpio_cfg_t stcGpioCfg;
    
    ///< 打开GPIO外设时钟门控
    Sysctrl_SetPeripheralGate(SysctrlPeripheralGpio, TRUE); 
    
    ///< 端口方向配置->输出(其它参数与以上（输入）配置参数一致)
    stcGpioCfg.enDir = GpioDirOut;
    ///< 端口上下拉配置->
    stcGpioCfg.enPu = GpioPuEnable;
    stcGpioCfg.enPd = GpioPdDisable;
	stcGpioCfg.enDrv = GpioDrvL;
//    stcGpioCfg.enOD = GpioOdEnable;
    ///< LED关闭
    Gpio_ClrIO(APP_LED_PORT, APP_LED_PIN);
    
    ///< GPIO IO LED端口初始化
    Gpio_Init(APP_LED_PORT, APP_LED_PIN, &stcGpioCfg);
	
//	Gpio_Init(APP_LED_UART_PORT, APP_LED_RX_PIN, &stcGpioCfg);
    
	Gpio_Init(APP_LED_SYS_PORT, APP_LED_SYS_PIN, &stcGpioCfg);
	
	//模拟开关测试
//	Gpio_Init(GpioPortC, GpioPin13, &stcGpioCfg);
//	Gpio_Init(GpioPortB, GpioPin9, &stcGpioCfg);
	
	

}

void led_set(_Bool status)
{
	if(status) {
		Gpio_SetIO(APP_LED_PORT, APP_LED_PIN);
		
	}else {
		Gpio_ClrIO(APP_LED_PORT, APP_LED_PIN);
	}
	
}
